package 美团;

import 树.TreeNode;

import java.util.LinkedList;
import java.util.List;

public class _145_二叉树的后序遍历 {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res = new LinkedList<>();
        postOrder(res, root);
        return res;
    }

    private void postOrder(List<Integer> res, TreeNode root) {
        if (root == null) return;
        postOrder(res, root.left);
        postOrder(res, root.right);
        res.add(root.val);
    }
}
